﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace INSTA.MusiqueStore.DAL
{
    public partial class Album
    {
        /// <summary>
        /// Gets the album duration.
        /// </summary>
        /// <value>The durée.</value>
        public int Durée
        {
            get
            {
                var c = new MusiqueStoreEntities();
                var d = (from piste in c.Pistes
                         where piste.IdAlbum == Id
                         select piste.Durée).Sum();
                return d;
            }
        }

        /// <summary>
        /// Gets the displayable duration.
        /// </summary>
        /// <value>The displayable duration.</value>
        public string DuréeAffichable
        {
            get { return Library.Tips.ToDisplayableTime(Durée); }
        }


        /// <summary>
        /// Gets the download image and link.
        /// </summary>
        /// <value>The download image and link.</value>
        public string AchatImageAndLink
        {
            get
            {
                var html = "<form method=\"post\" action=\"AchatAlbum.aspx\"><input type=\"hidden\" name=\"i\" value=\"" + Id + "\"><input type=\"image\" src=\"achat.png\" /></form>";
                //"<a href=\"mp3/" + LienFichier + "\"><img src=\"dl.png\"/></a>";
                return html;
            }

        }
    }
}
